/**  
 * All rights Reserved, Designed By www.tydic.com
 * @Title:  UserServiceImpl.java   
 * @Package com.axin.service.impl   
 * @Description:    TODO(用一句话描述该文件做什么)   
 * @author: axin     
 * @date:   2019年3月17日 下午8:58:54   
 * @version V1.0 
 * @Copyright: 2019 www.hao456.top Inc. All rights reserved. 
 */
package com.axin.service.impl;

import java.util.Date;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import com.axin.dao.HbUserMapper;
import com.axin.entity.HbUser;
import com.axin.entity.example.HbUserExample;
import com.axin.service.UserService;

/**   
 * @Description: 用户服务层 
 * @ClassName:  UserServiceImpl
 * @author:  Axin 
 * @date:   2019年3月17日 下午8:58:54   
 * @Copyright: 2019 www.hao456.top Inc. All rights reserved. 
 */
@Service
public class UserServiceImpl implements UserService{

	
	@Autowired
	private HbUserMapper userMapper;
	/* (non-Javadoc)
	 * @see com.axin.service.UserService#getUserByEmail(java.lang.String)
	 */
	@Override
	public HbUser getUserByEmail(String email) {
		HbUserExample example = new HbUserExample();
		example.createCriteria().andEmailEqualTo(email);
		List<HbUser> list = this.userMapper.selectByExample(example);
		if(CollectionUtils.isNotEmpty(list)){
			return list.get(0);
		}
		return null;
	}
	/* (non-Javadoc)
	 * @see com.axin.service.UserService#createUser(com.axin.entity.HbUser)
	 */
	@Override
	public void createUser(HbUser user) {
		user.setCreateTime(new Date());
		user.setUpdateTime(new Date());
		user.setNickname(user.getEmail());
		user.setPassword(DigestUtils.md5DigestAsHex(user.getPassword().getBytes()));
		this.userMapper.insert(user);
	}

	
	
	
	
	
}
